package clueless.utilities;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

public class Connection {

	private Socket         m_socket;
	private PrintWriter    m_outputStream;
	private BufferedReader m_inputStream;

	public void connectToServer() {

		try {
			m_socket       = new Socket(Constants.m_SERVER_IP_ADDRESS, Constants.m_SERVER_PORT);
			m_inputStream  = new BufferedReader(new InputStreamReader(m_socket.getInputStream()));
			m_outputStream = new PrintWriter(m_socket.getOutputStream());
   			
			System.out.println("Server connection made");
		}
		catch(Exception ex) {
			ex.printStackTrace();
		}

	}

	public void connectToClient(Socket clientSocket) {

		try {
			m_socket       = clientSocket;
			m_outputStream = new PrintWriter(clientSocket.getOutputStream());
			m_inputStream  = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));

			System.out.println("Client connection made");
		}
		catch(Exception ex) {
			ex.printStackTrace();
		}

	}
	
	public Socket getSocket() {
		return m_socket;
	}

	public BufferedReader getInputStream() {
		return m_inputStream;
	}
	
	public PrintWriter getOutputStream() {
		return m_outputStream;
	}

}
